#include "../include/thread_pool.h"
int init_ThreadPool(pThreadPool_t pPool,int thread_num){
    pPool->thread_num=thread_num;
    pPool->boot = 0;
    pPool->pthid= (pthread_t *)calloc(thread_num,sizeof(pthread_t));
    init_TaskQueue(&pPool->que);
    return 0;
} //初始化线程池                  
int boot_ThreadPool(pThreadPool_t pPool){
    if(0 == pPool->boot){
        for(int i  = 0;i<pPool->thread_num;++i){
            pthread_create(pPool->pthid+i,NULL,child_handle,&pPool->que);
        }
    
        pPool->boot=1;
    }
    return 0;

} //启动线程池
int close_ThreadPool(pThreadPool_t pPool){
    if(pPool->boot == 1){
        for(int i =  0;i<pPool->thread_num;++i){
            pthread_join(pPool->pthid[i],NULL);

        }
        pPool->boot = 1;
    }
    return 0;
} //关闭线程池
int destroy_ThreadPool(pThreadPool_t pPool){
    free(pPool->pthid);
    pPool->boot = 0;
    return 0;
} //销毁线程池

